package workflow

import (
	"context"
	"fmt"
	"github.com/cloudwego/eino/components/document/parser"

	"github.com/cloudwego/eino-ext/components/document/loader/file"
	"github.com/cloudwego/eino-ext/components/document/loader/url"
	"github.com/cloudwego/eino/components/document"
)

// newLoader component initialization function of node 'outcomeImage' in graph 'riskChecker'
func newLoader(ctx context.Context) (ldr document.Loader, err error) {

	config := &url.LoaderConfig{}
	parse, err := parser.NewExtParser(ctx,
		&parser.ExtParserConfig{
			FallbackParser: parser.TextParser{},
		},
	)
	if err != nil {
		return nil, fmt.Errorf("new file parser fail: %w", err)
	}
	config.Parser = parse
	ldr, err = url.NewLoader(ctx, config)
	if err != nil {
		return nil, err
	}
	return ldr, nil
}

// newLoader1 component initialization function of node 'riskRules' in graph 'riskChecker'
func newLoader1(ctx context.Context) (ldr document.Loader, err error) {
	// TODO Modify component configuration here.
	config := &file.FileLoaderConfig{}

	ldr, err = file.NewFileLoader(ctx, config)
	if err != nil {
		return nil, err
	}
	return ldr, nil
}
